<!-- include tpl=head title=$page_rs.title -->
<script type="text/javascript">
$(document).ready(function(){
	var is_vcode = '<!-- if $is_vcode -->true<!-- else -->false<!-- /if -->';
	$("#post_submit").submit(function(){
		if(!$("#title").val()){
			$.dialog.alert('{$page_rs.alias_title ? $page_rs.alias_title : "主题"}不能为空');
			return false;
		}
		if(is_vcode == 'true'){
			var chkcode = $("#_chkcode").val();
			if(!chkcode){
				$.dialog.alert('验证码不能为空');
				$("#_vcode").phpok_vcode();
				return false;
			}
		}
		$(this).ajaxSubmit({
			'url':api_url('post','save'),
			'type':'post',
			'dataType':'json',
			'success':function(rs){
				if(rs.status == 'ok'){
					$.dialog.alert('内容添加成功',function(){
						window.close();
					});
				}else{
					$.dialog.alert(rs.content,function(){
						$("#_vcode").phpok_vcode();
						$("#_chkcode").val('');
					});
					return false;
				}
			}
		});
		return false;
	});
});
</script>
<div class="am-text-center am-margin am-btn-lg">添加</div>
<form method="post" id="post_submit" class="am-form">
<input type="hidden" name="id" id="id" value="{$page_rs.identifier}" />
<!-- if $cate_rs -->
<input type="hidden" name="cate_id" id="cate_id" value="{$cate_rs.id}" />
<!-- /if -->
<div class="am-g am-form-group">
	<label class="am-u-sm-12" for="title">{$page_rs.alias_title ? $page_rs.alias_title : '主题'}</label>
	<div class="am-u-sm-12"><input type="text" name="title" id="title" /></div>
</div>
<!-- if $catelist && !$cate_rs -->
<div class="am-g am-form-group">
	<label class="am-u-sm-12" for="title">分类</label>
	<div class="am-u-sm-12">
		<select name="cate_id" id="cate_id">
			<option value="">请选择分类……</option>
			<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
			<option value="{$value.id}"{if $cate_rs.id == $value.id} selected{/if}>{$value._space}{$value.title}</option>
			<!-- /loop -->
		</select>
	</div>
</div>
<!-- /if -->
<!-- fields pid=$page_rs.id fields_format=1 -->
<!-- loop from=$list key=$key value=$value -->
<div class="am-g am-form-group">
	<label class="am-u-sm-12" for="{$value.identifier}">{$value.title}</label>
	<div class="am-u-sm-12">{$value.html}</div>
</div>
<!-- /loop -->
<!-- if $is_vcode -->
<div class="am-g am-form-group">
	<label class="am-u-sm-12" for="_chkcode">验证码：</label>
	<div class="am-u-sm-6"><input type="text" name="_chkcode" id="_chkcode" class="vcode" /></div>
	<div class="am-u-sm-6"><img src="" border="0" align="absmiddle" id="update_vcode" class="hand"></div>
	<script type="text/javascript">
	$(document).ready(function(){
		$("#update_vcode").phpok_vcode();
		//更新点击时操作
		$("#update_vcode").click(function(){
			$(this).phpok_vcode();
		});
	});
	</script>
</div>
<!-- /if -->
<div class="am-margin-sm"><input type="submit" value=" 提交 " class="am-btn am-btn-block am-btn-primary" /></div>

</form>


<!-- include tpl=foot -->